package spring.chatroom.java_chatroom.common.constant;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

/**
 * #{username}  #{code}  #{loginUrl}
 **/
public class VerifyHtml {

    public static String setLoginHtml(String code) {
        String html = """
                <!DOCTYPE html>
                <html lang="zh-CN">
                <head>
                    <meta charset="UTF-8">
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
                    <title>网页聊天登录验证码</title>
                    <style>
                        * {
                            margin: 0;
                            padding: 0;
                            box-sizing: border-box;
                            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
                        }
                       \s
                        body {
                            background-color: #f5f7fa;
                            padding: 20px;
                            color: #333;
                        }
                       \s
                        .container {
                            max-width: 600px;
                            margin: 0 auto;
                            background: white;
                            border-radius: 8px;
                            overflow: hidden;
                            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
                        }
                       \s
                        .header {
                            background: linear-gradient(135deg, #1e88e5, #0d47a1);
                            padding: 25px 30px;
                            text-align: center;
                        }
                       \s
                        .logo {
                            color: white;
                            font-size: 24px;
                            font-weight: 600;
                            letter-spacing: 1px;
                        }
                       \s
                        .content {
                            padding: 40px 30px;
                        }
                       \s
                        .title {
                            font-size: 22px;
                            font-weight: 600;
                            margin-bottom: 25px;
                            color: #1a237e;
                            text-align: center;
                        }
                       \s
                        .greeting {
                            margin-bottom: 30px;
                            line-height: 1.6;
                        }
                       \s
                        .code-container {
                            background: #f1f8fe;
                            border-radius: 8px;
                            padding: 25px;
                            text-align: center;
                            margin: 30px 0;
                            border: 1px dashed #90caf9;
                        }
                       \s
                        .code-label {
                            font-size: 16px;
                            color: #546e7a;
                            margin-bottom: 15px;
                        }
                       \s
                        .verification-code {
                            font-size: 42px;
                            font-weight: 700;
                            letter-spacing: 1px; /* 间距从8px调整为4px */
                            color: #0d47a1;
                            padding: 10px 0;
                        }
                       \s
                        .expiration {
                            color: #e53935;
                            font-weight: 500;
                            margin: 20px 0;
                            text-align: center;
                        }
                       \s
                    </style>
                </head>
                <body>
                    <div class="container">
                        <div class="header">
                            <div class="logo">网页聊天系统</div>
                        </div>
                       \s
                        <div class="content">
                            <h1 class="title">您的登录验证码</h1>
                           \s
                            <div class="greeting">
                                <p>您正在登录网页聊天系统，请使用以下验证码完成身份验证：</p>
                            </div>
                           \s
                            <div class="code-container">
                                <div class="code-label">验证码</div>
                                <div class="verification-code">#{code}</div> <!-- 移除数字间的空格 -->
                            </div>
                           \s
                            <p class="expiration">此验证码将在 <strong>5分钟</strong> 后失效</p>
                           \s
                        </div>
                       \s
                    </div>
                </body>
                </html>
                """;
        return html.replace("#{code}", code);
    }

    public static String setBindHtml(String name, String code) {
        String html = """
                <!DOCTYPE html>
                <html lang="zh-CN">
                <head>
                    <meta charset="UTF-8">
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
                    <title>绑定邮箱验证码</title>
                    <style>
                        * {
                            margin: 0;
                            padding: 0;
                            box-sizing: border-box;
                            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
                        }
                       \s
                        body {
                            background-color: #f5f7fa;
                            padding: 20px;
                            color: #333;
                        }
                       \s
                        .container {
                            max-width: 600px;
                            margin: 0 auto;
                            background: white;
                            border-radius: 8px;
                            overflow: hidden;
                            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
                        }
                       \s
                        .header {
                            background: linear-gradient(135deg, #1e88e5, #0d47a1);
                            padding: 25px 30px;
                            text-align: center;
                        }
                       \s
                        .logo {
                            color: white;
                            font-size: 24px;
                            font-weight: 600;
                            letter-spacing: 1px;
                        }
                       \s
                        .content {
                            padding: 40px 30px;
                        }
                       \s
                        .title {
                            font-size: 22px;
                            font-weight: 600;
                            margin-bottom: 25px;
                            color: #1a237e;
                            text-align: center;
                        }
                       \s
                        .greeting {
                            margin-bottom: 30px;
                            line-height: 1.6;
                        }
                       \s
                        .code-container {
                            background: #f1f8fe;
                            border-radius: 8px;
                            padding: 25px;
                            text-align: center;
                            margin: 30px 0;
                            border: 1px dashed #90caf9;
                        }
                       \s
                        .code-label {
                            font-size: 16px;
                            color: #546e7a;
                            margin-bottom: 15px;
                        }
                       \s
                        .verification-code {
                            font-size: 42px;
                            font-weight: 700;
                            letter-spacing: 1px; /* 间距从8px调整为4px */
                            color: #0d47a1;
                            padding: 10px 0;
                        }
                       \s
                        .expiration {
                            color: #e53935;
                            font-weight: 500;
                            margin: 20px 0;
                            text-align: center;
                        }
                       \s
                    </style>
                </head>
                <body>
                    <div class="container">
                        <div class="header">
                            <div class="logo">网页聊天系统</div>
                        </div>
                       \s
                        <div class="content">
                            <h1 class="title">您的登录验证码</h1>
                           \s
                            <div class="greeting">
                                <p>尊敬的 <strong>#{username}</strong>，您好！</p>
                                <p>您正在绑定邮箱，请使用以下验证码完成身份验证：</p>
                            </div>
                           \s
                            <div class="code-container">
                                <div class="code-label">验证码</div>
                                <div class="verification-code">#{code}</div> <!-- 移除数字间的空格 -->
                            </div>
                           \s
                            <p class="expiration">此验证码将在 <strong>5分钟</strong> 后失效</p>
                           \s
                        </div>
                       \s
                    </div>
                </body>
                </html>
                """;
        return html.replace("#{username}", name).replace("#{code}", code);
    }
}
